package com.jzo2o.orders.manager.hander;

import com.jzo2o.orders.base.model.domain.Orders;
import com.jzo2o.orders.manager.model.dto.request.PlaceOrderReqDTO;
import lombok.extern.slf4j.Slf4j;

import java.math.BigDecimal;

/**
 * @Author: lzj
 * 计算订单价格处理类
 */
@Slf4j
public class CalculateOrderHandler extends OrderHandler {
    @Override
    public void process(Orders orders, PlaceOrderReqDTO reqDTO) {
        log.info("计算订单价格处理");
        //计算价格
        BigDecimal totalAmount = orders.getPrice().multiply(new BigDecimal(orders.getPurNum()));
        //优惠价格 TODO  暂时设置为0
        BigDecimal discountAmount = BigDecimal.ZERO;
        orders.setDiscountAmount(discountAmount);
        orders.setTotalAmount(totalAmount);
        //实际支付价格
        orders.setRealPayAmount(totalAmount.subtract(discountAmount));
        orderHandler.process(orders, reqDTO);
    }
}
